package com.fuze.energy.controller;

import com.fuze.energy.common.Result;
import com.fuze.energy.domain.dto.UserDTO;
import com.fuze.energy.domain.entity.User;
import com.fuze.energy.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sepc_
 * @date 7/29/2021 15:44
 */
@Api(tags = "用户模块")
@RestController
@Slf4j
@RequiredArgsConstructor
public class UserController {

    final UserService userService;

    @ApiOperation(value = "用户登录接口")
    @PostMapping("/user/login")
    public Result login(@RequestBody @Validated UserDTO userDTO) {
        User user = userService.doLogin(userDTO);
        return Result.ok(user);
    }

}
